package com.example;

import com.example.model.Product;
import com.example.model.Student;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * 启动类：Spring XML 版 IoC 容器示例
 *
 * @author 某某
 * @since 2025-09-23
 */
public class App {

    /**
     * 入口方法
     *
     * 1. 装载 Spring 容器
     * 2. 取出 Product 与 Student Bean
     * 3. 控制台打印
     */
    public static void main(String[] args) {
        /* ---------------- 装载容器 ---------------- */
        ApplicationContext ctx =
                new ClassPathXmlApplicationContext("applicationContext.xml");

        /* ---------------- 获取 Bean --------------- */
        Product product = ctx.getBean("product", Product.class);
        Student student = ctx.getBean("student", Student.class);

        /* ---------------- 打印结果 ---------------- */
        System.out.println(">>>> 从 Spring 容器中获取的 Bean <<<<");
        System.out.println(product);
        System.out.println(student);
    }
}